import request from '@/utils/request'

export function findAll() {
  return request({
    url: process.env.VUE_APP_PATH + '/estates/findAll',
    method: 'get'
  })
}

export function page(page, pageSize) {
  return request({
    url: process.env.VUE_APP_PATH + '/estates?page=' + page + '&pageSize=' + pageSize,
    method: 'get'
  })
}

export function add(estate) {
  return request({
    url: process.env.VUE_APP_PATH + '/estates',
    method: 'post',
    data: estate
  })
}

export function update(estate) {
  return request({
    url: process.env.VUE_APP_PATH + '/estates',
    method: 'put',
    data: estate
  })
}

export function deleteById(id) {
  return request({
    url: process.env.VUE_APP_PATH + '/estates/' + id,
    method: 'delete'
  })
}

export function selectById(id) {
  return request({
    url: process.env.VUE_APP_PATH + '/estates/' + id,
    method: 'get'
  }).then(res => {
    const data = res.data.data[0]
    res.data.data = data
    return res
  })
}
